import cn.fudan.dsm.preprocess.XlsxReader;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by 80494 on 2017/5/25.
 */
public class main {
    public static void main(String[] args) throws Exception {
        String file1 = "E:\\故障检测\\服务请求及其任务单.xlsx";
        String file2 = "E:\\故障检测\\故障工单.xlsx";
        XlsxReader r1 = new XlsxReader();
        XlsxReader r2 = new XlsxReader();
        List<List<Map<String, String>>> result1 = new ArrayList<List<Map<String, String>>>();
        List<List<Map<String, String>>> result2 = new ArrayList<List<Map<String, String>>>();
        result1 =  XlsxReader.readExcelWithTitle(file1);
        result2 =  XlsxReader.readExcelWithTitle(file2);


        FileWriter fw1 = new FileWriter("E:\\故障检测\\服务请求及其任务单文本");
        BufferedWriter  bw1=new BufferedWriter(fw1);
        for (List<Map<String,String>> maplist:result1) {
            for (Map<String,String> map:maplist) {
                for (Map.Entry<String,String> m:map.entrySet()) {
                    //if(m.getKey().toString()!="工单编号" && m.getKey().toString()!="相关记录工单编号"){
                    bw1.write(m.getKey()+":\n"+m.getValue()+"\n");
                    //}
                }
            }
            bw1.write("\n");
        }
        bw1.close();
        fw1.close();

        FileWriter fw2 = new FileWriter("E:\\故障检测\\故障工单文本");
        BufferedWriter  bw2=new BufferedWriter(fw2);
        for (List<Map<String,String>> maplist:result2) {
            for (Map<String,String> map:maplist) {
                for (Map.Entry<String,String> m:map.entrySet()) {
                    //if(m.getKey().toString()!="工单编号" && m.getKey().toString()!="相关记录工单编号"){
                        bw2.write(m.getKey()+":\n"+m.getValue()+"\n");
                    //}
                }
            }
            bw2.write("\n");
        }
        bw2.close();
        fw2.close();




        //test jsonConverter
        //String j1 = ConvertToJson.toJsonString(result1);
        //String j2 = ConvertToJson.toJsonString(result2);
        //JSONObject json1 = JSONObject.parseObject(j1);
        //JSONObject json2 = JSONObject.parseObject(j2);



        //System.out.println(result1);
        //System.out.println(result2);
       //WordSegmentation ws = new WordSegmentation();
    }
}
